package com.spring.demo6.eg8;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author vhans
 */
@Configuration
public class MainConfig11 {
    @Bean
    public Service1 service1() {
        return new Service1();
    }

    @Bean
    public Service2 service2() {
        return new Service2();
    }

    @Bean
    public Service3 service3(Service1 service1, Service2 service2) {
        // 3.@Bean结合方法参数的方式注入依赖
        Service3 service3 = new Service3();
        service3.setService1(service1);
        service3.setService2(service2);
        return service3;
    }
}
